package com.glasses.controller;

import com.alibaba.fastjson.JSONObject;
import com.glasses.orm.base.Ex.BaseControllerEx;
import com.glasses.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * Created by ashin on 2018/1/24.
 */
@Controller
@Scope("prototype")
@RequestMapping("/user")
public class UserController extends BaseControllerEx {

    @Autowired
    UserService userService;

    @Override
    protected void init() {
        super.init(userService);
    }

    @RequestMapping(value = "/doLogin")
    public JSONObject doLogin(@RequestParam Map map) throws Exception{
        return userService.login(map,session);
    }

    @RequestMapping(value = "/doGetUserInfo")
    public JSONObject doGetUserInfo(@RequestParam Map map) throws Exception{
        Object object = session.getAttribute("user");
        if(object == null){
            return this.codeMess(eCode,"登录失效");
        }
        return this.codeData(object);
    }

    @RequestMapping(value = "/doGetMyIndent")
    public JSONObject doGetMyIndent(@RequestParam Map map) throws Exception{
        return userService.getMyIndent(map);
    }

    public static void main(String[] args) {
        Object o = 5.2;
        System.err.println(o instanceof Double);
    }
}
